package com.member.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.member.common.enums.DeleteEnum;
import com.member.common.utils.DateUtils;
import com.member.shop.domain.SysBizHot;
import com.member.shop.mapper.SysBizHotMapper;
import com.member.shop.service.ISysBizHotService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;


/**
 * 热门搜索Service业务层处理
 *
 * @author lixinchen
 * @date 2024-12-17
 */
@Service
public class SysBizHotServiceImpl extends ServiceImpl<SysBizHotMapper, SysBizHot> implements ISysBizHotService {
    @Resource
    private SysBizHotMapper sysBizHotMapper;

    /**
     * 查询热门搜索
     *
     * @param id 热门搜索主键
     * @return 热门搜索
     */
    @Override
    public SysBizHot selectSysBizHotById(Long id) {
        return sysBizHotMapper.selectById(id);
    }

    /**
     * 查询热门搜索列表
     *
     * @param queryWrapper 热门搜索
     * @return 热门搜索
     */
    @Override
    public List<SysBizHot> selectSysBizHotList(LambdaQueryWrapper<SysBizHot> queryWrapper) {
        return sysBizHotMapper.selectList(queryWrapper);
    }

    /**
     * 新增热门搜索
     *
     * @param sysBizHot 热门搜索
     * @return 结果
     */
    @Override
    public int insertSysBizHot(SysBizHot sysBizHot) {
        sysBizHot.setCreateTime(DateUtils.getNowDate());
        return sysBizHotMapper.insert(sysBizHot);
    }

    /**
     * 修改热门搜索
     *
     * @param sysBizHot 热门搜索
     * @return 结果
     */
    @Override
    public int updateSysBizHot(SysBizHot sysBizHot) {
        sysBizHot.setUpdateTime(DateUtils.getNowDate());
        return sysBizHotMapper.updateById(sysBizHot);
    }

    /**
     * 批量删除热门搜索
     *
     * @param ids 需要删除的热门搜索主键
     * @return 结果
     */
    @Override
    public int deleteSysBizHotByIds(Long[] ids) {
        return sysBizHotMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除热门搜索信息
     *
     * @param id 热门搜索主键
     * @return 结果
     */
    @Override
    public int deleteSysBizHotById(Long id) {
        SysBizHot sysBizHot = new SysBizHot();
        sysBizHot.setId(id);
        sysBizHot.setDeleted(DeleteEnum.DELETE.getKey());
        return sysBizHotMapper.updateById(sysBizHot);
    }
}
